#include "widget.h"
#include "ui_widget.h"
#include<QDebug>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{

     QDateTime timeOld =  ui->dateTimeEdit->dateTime();
       QDateTime timeNew =  ui->dateTimeEdit_2->dateTime();
       qDebug()<<timeOld<<timeNew;

       //计算日期的差值
       
       
         //计算秒数的差值
                  int seconds =timeOld.secsTo(timeNew);
                              int hours = (seconds/3600) %24;
                                            qDebug()<<hours<<timeNew;
                                                          //  int days =timeOld.daysTo(timeNew);
                                                                        int days =(seconds/3600)/24;
                                                                                            qDebug()<<days<<timeNew;
       
                                                                                                          ui->label->setText(QString::number(hours)) ;
                                                                                                          }
       
